package org.example.testdemo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.example.testdemo.mapper.DepartmentMapper;
import org.example.testdemo.pojo.Department;
import org.example.testdemo.service.DepartmentService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Resource
    private DepartmentMapper departmentMapper;

    @Override
    public List<Department> departmentlList() {
        return departmentMapper.selectList(null);
    }

    @Override
    public String findByBCode(String bCode) {
        Department code = departmentMapper.selectOne(new QueryWrapper<Department>().eq("b_Code", bCode));
        if(code==null){
            return null;
        }
        return code.getBCode()+"/"+code.getBName();
    }
}
